#ifndef SERIALLIST_H
#define SERIALLIST_H

#include <QObject>
#include <QSerialPortInfo>
#include <QMap>
#include "serialthread.h"


class SerialList : public QObject
{
public:
    SerialList(QObject *parent = nullptr);
    ~SerialList();

    QStringList SerialRefresh();
    void writeDataToSerial(int devIndex,QString devname,QString portname,int BaudRate,int DataBits,int Parity,int StopBits,int waitMSEC,QString datastr);
    void testEmit();

    // 设置回调函数的函数
    void setCallbackFunc(void(*func) (int devIndex,QString devName,QString res));

private:
        void(*m_callbackFunc)(int devIndex,QString devName,QString res);
signals:
    void response(const QString &s);
    void error(const QString &s);
    void timeout(const QString &s);
private slots:
    void transaction();
    void showRequest(int devIndex,const QString &devName,const QString &res);
    void processError(const QString &s);
    void processTimeout(const QString &s);
};

#endif // SERIALLIST_H
